package com.ytxg.health_management.controller;

import com.ytxg.health_management.pojo.entity.Result;
import com.ytxg.health_management.util.MyException;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

@ControllerAdvice
public class ErrorControllerAdvice {

    @ResponseBody
    @ExceptionHandler(MyException.class)
    public Result<String> handleException(MyException e) {

        return Result.fail(e.getCode(),e.getMessage());
    }

}
